"""
#!!===========================================================
#版权（C）2023, Huawei Technologies Co., HUTAF xDevice
#!!===========================================================
#用例编号:      Security_IAM_AuthWidget_Pin_Auth_Func_0005
#用例名称:      6位数字认证失败口令锁定后等待冻结时间结束
#用例作者:
#修改说明:
#!!===========================================================
"""

# -*- coding: utf-8 -*-
from devicetest.core.test_case import TestCase
from devicetest.aw.OpenHarmony import CommonOH
from aw.Useriam.AuthWidget import SecurityUserIamAuthWidgetPinAuth
from aw.Useriam.AuthWidget import SecurityUserIamAuthWidgetDepend


class Security_IAM_AuthWidget_Pin_Auth_Func_0005(TestCase):

    def __init__(self, controllers):
        self.TAG = self.__class__.__name__
        self.tests = [
            "test_step1"
        ]
        TestCase.__init__(self, self.TAG, controllers)

    def setup(self):
        print("预置工作：认证失败4次............")
        SecurityUserIamAuthWidgetDepend.widget(self.device1, "1", "10000", "口令认证", "", "1")
        for i in range(4):
            SecurityUserIamAuthWidgetPinAuth.PinAuth(self.device1, "113456", 0)
        CommonOH.goHome(self.device1)

    def test_step1(self):
        print("测试步骤1：测试hap拉起口令认证")
        SecurityUserIamAuthWidgetDepend.widget(self.device1, "1", "10000", "口令认证", "", "1")
        print("测试步骤2：使用错误口令认证")
        SecurityUserIamAuthWidgetPinAuth.PinAuth(self.device1, "113456", 0)
        print("检查点2：认证锁定，控件存在")
        CommonOH.checkIfTextExist(self.device1, "失败次数过多", expect=True)
        print("测试步骤3：等待60s结束")
        CommonOH.wait(self.device1, 60)
        print("测试步骤4：使用正确口令认证")
        SecurityUserIamAuthWidgetPinAuth.PinAuth(self.device1, "123456", 0)
        print("检查点4：认证成功，控件退出")
        CommonOH.checkIfTextExist(self.device1, "12500000", expect=True)

